package com.glitech.demo.data;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface VoiceCmdDao {
    /** Read **/
    @Query("SELECT * FROM word_table")
    List<VoiceCmd> getCommands();

    @Query("SELECT action FROM word_table WHERE word=(:word)")
    String queryAction(String word);

    @Query("SELECT * FROM word_table WHERE word=(:word)")
    List<VoiceCmd> query(String word);


    /** Create **/
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    void insert(VoiceCmd cmd);

    /** Delete **/
    @Delete
    void delete(VoiceCmd cmd);

    @Query("DELETE FROM word_table WHERE word=(:word)")
    void delete(String word);

    @Query("DELETE FROM word_table")
    void deleteAll();

    /** Update **/
    @Update(onConflict = OnConflictStrategy.IGNORE)
    void update(VoiceCmd cmd);
}
